var ishop = ishop || {};


function doAjax(url,paraBean,callback,dt){
    var dataType = dt||"json";
    $.ajax({
        url:url,
        type:"post",
        dataType:dataType,
        data:paraBean,
        cache:false,
        error :function(){
            alert("操作失败!");
        },
        success:function(data){
            if(callback != null){
                callback(data);
            }
        }
    });
}

/**
 * iframe自适应高度
 *
 * @param iframe
 */
ishop.autoIframeHeight = function(iframe) {
    iframe.style.height = iframe.contentWindow.document.body.scrollHeight + "px";
};

/**
 * 将form表单元素的值序列化成对象
 * @example ishop.serializeObject($('#formId'))
 * @requires jQuery
 * @returns object
 */
ishop.serializeObject = function(form) {
    var o = {};
    $.each(form.serializeArray(), function(index) {
        if (this['value'] != undefined && this['value'].length > 0) {// 如果表单项的值非空，才进行序列化操作
            if (o[this['name']]) { //多相同input name以,号隔开
                o[this['name']] = o[this['name']] + "," + this['value'];
            } else {
                o[this['name']] = this['value'];
            }
        }
    });
    return o;
};

ishop.kkpager = function(pageNo,pageCount,totalRecord,callback,pagerId){
    kkpager.generPageHtml({
        pagerid:pagerId?pagerId:"kkpager",
        pno: pageNo,
        total: pageCount,//总页码
        totalRecords: totalRecord, //总数据条数
        mode: 'click',//默认值是link，可选link或者click
        isGoPage: false,
        click: function (n) {
            callback(n);
            return false;
        }
    });
};
